/*
 * Displayer.java
 *
 * Created on May 7, 2007, 12:11 PM
 */

package dva.displayer;

import java.awt.GraphicsConfiguration;

/**
 *
 * @author  J-Chris
 */
public class Displayer extends javax.swing.JFrame {
    
    /**
     * Creates new form Displayer
     */
    public Displayer(GraphicsConfiguration gc) {
        super(gc);
        instance = this; 
        initComponents();
        initSpecificComponents(); 
    }
    
    public static Displayer getInstance(){
        return instance; 
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DVA Displayer");
        setBackground(new java.awt.Color(255, 255, 255));
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 522, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 326, Short.MAX_VALUE)
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void initSpecificComponents(){
        
        //instanciate the View
        displayView = new DisplayView(this);
        
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(displayView, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(displayView, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        
        //instanciate the Model
        displayModel = new DisplayModel(); 
        
        //register the observer
        displayModel.addObserver(displayView);
        
        displayView.addComponentListener(displayModel); 
        
        resizeDisplayer();
        
    }
    
    public void resizeDisplayer(){
       this.setExtendedState(this.MAXIMIZED_BOTH == this.getExtendedState() ? this.NORMAL : this.MAXIMIZED_BOTH); 
    }
    
    public DisplayModel getDisplayModel(){
        return displayModel; 
    }
    
    public boolean isCalibrated(){
        return isCalibrated; 
    }
    
    
    private boolean isCalibrated = false;  
    private DisplayView displayView; 
    private DisplayModel displayModel; 
    private static Displayer instance; 
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
